package homework;
//作业标题(982)
//2.删除排序数组中的重复项
//
//作业内容
//2.删除排序数组中的重复项
//https://leetcode.cn/problems/remove-duplicates-from-sorted-array/description/
public class h982 {
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if(n == 0) return 0;

        int lost = 1, fast = 1;
        while(fast < n)
        {
            if(nums[fast - 1] != nums[fast])
            {
                nums[lost] = nums[fast];
                lost++;
            }
            fast++;
        }

        return lost;
    }

    public static void main(String[] args) {
        System.out.println(new h982().removeDuplicates(new int[]{1, 1, 2}));
    }
}
